home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / plnk081.zip / pilot-link.0.8.1 / include / pi-dlp.h < prev    next >
C/C++ Source or Header  |  1997-08-08  |  12KB  |  341 lines

  1. #ifndef _PILOT_DLP_H_
  2. #define _PILOT_DLP_H_
  3.  
  4. #include "pi-args.h"
  5.  
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9.  
  10. #include "pi-macros.h" /* For recordid_t */
  11.  
  12. /* Note: All of these functions return an integer that if greater then zero
  13.    is the number of bytes in the result, zero if there was no result, or
  14.    less then zero if an error occured. Any return fields will be set to zero
  15.    if an error occurs. All calls to dlp_* functions should check for a 
  16.    return value less then zero. */
  17.    
  18. struct PilotUser {
  19.   unsigned long userID, viewerID, lastSyncPC;
  20.   time_t successfulSyncDate, lastSyncDate;
  21.   char username[128];
  22.   int passwordLength;
  23.   char password[128];
  24. };
  25.  
  26. struct SysInfo {
  27.   unsigned long romVersion;
  28.   unsigned long locale;
  29.   int nameLength;
  30.   char name[128];
  31. };
  32.  
  33. struct DBInfo {
  34.   int more;
  35.   unsigned int flags;
  36.   unsigned int miscFlags;
  37.   unsigned long type,creator;
  38.   unsigned int version;
  39.   unsigned long modnum;
  40.   time_t createDate,modifyDate,backupDate;
  41.   unsigned int index;
  42.   char name[34];
  43. };
  44.  
  45. struct CardInfo {
  46.     int card;
  47.     int version;
  48.     time_t creation;
  49.     unsigned long romSize, ramSize, ramFree;
  50.     char name[128];
  51.     char manufacturer[128];
  52.     
  53.     int more;
  54. };
  55.  
  56. struct NetSyncInfo {
  57.   int lanSync;
  58.   char hostName[256]; /* Null terminated string */
  59.   char hostAddress[40]; /* Null terminated string */
  60.   char hostSubnetMask[40]; /* Null terminated string */
  61. };
  62.  
  63. enum dlpDBFlags {
  64.     dlpDBFlagResource = 0x0001, /* Resource DB, instead of record DB */
  65.     dlpDBFlagReadOnly = 0x0002, /* DB is read only */
  66.     dlpDBFlagAppInfoDirty = 0x0004, /* AppInfo data has been modified */
  67.     dlpDBFlagBackup = 0x0008, /* DB is tagged for generic backup */
  68.     dlpDBFlagOpen = 0x8000, /* DB is currently open */
  69.     
  70.     /* v2.0 specific */
  71.     dlpDBFlagNewer = 0x0010, /* Newer version may be installed over open DB */
  72.     dlpDBFlagReset = 0x0020 /* Reset after installation */
  73. };
  74.  
  75. enum dlpDBMiscFlags {
  76.     dlpDBMiscFlagExcludeFromSync = 0x80
  77. };
  78.  
  79. enum dlpRecAttributes {
  80.     dlpRecAttrDeleted = 0x80, /* tagged for deletion during next sync */
  81.     dlpRecAttrDirty   = 0x40, /* record modified */
  82.     dlpRecAttrBusy    = 0x20, /* record locked  */
  83.     dlpRecAttrSecret  = 0x10, /* record is secret*/
  84.     dlpRecAttrArchived= 0x08 /* tagged for archival during next sync*/
  85. };
  86.  
  87. enum dlpOpenFlags {
  88.         dlpOpenRead = 0x80,
  89.         dlpOpenWrite = 0x40,
  90.         dlpOpenExclusive = 0x20,
  91.         dlpOpenSecret = 0x10,
  92.         dlpOpenReadWrite = 0xC0
  93. };
  94.  
  95. enum dlpEndStatus {
  96.         dlpEndCodeNormal = 0,  /* Normal */
  97.         dlpEndCodeOutOfMemory, /* End due to low memory on Pilot */
  98.         dlpEndCodeUserCan,     /* Cancelled by user */
  99.         dlpEndCodeOther        /* dlpEndCodeOther and higher mean "Anything else" */
  100. };
  101.  
  102. enum dlpDBList {
  103.     dlpDBListRAM = 0x80,
  104.     dlpDBListROM = 0x40
  105. };
  106.  
  107. enum dlpErrors { 
  108.   dlpErrNoError = -1,
  109.   dlpErrSystem  = -2,
  110.   dlpErrMemory  = -3,
  111.   dlpErrParam   = -4,
  112.   dlpErrNotFound = -5,
  113.   dlpErrNoneOpen = -6,
  114.   dlpErrAlreadyOpen = -7,
  115.   dlpErrTooManyOpen = -8,
  116.   dlpErrExists = -9,
  117.   dlpErrOpen = -10,
  118.   dlpErrDeleted = -11,
  119.   dlpErrBusy = -12,
  120.   dlpErrNotSupp = -13,
  121.   dlpErrUnused1 = -14,
  122.   dlpErrReadOnly = -15,
  123.   dlpErrSpace = -16,
  124.   dlpErrLimit = -17,
  125.   dlpErrSync = -18,
  126.   dlpErrWrapper = -19,
  127.   dlpErrArgument = -20,
  128.   dlpErrSize = -21,
  129.   dlpErrUnknown = -128
  130. };
  131.  
  132. extern char * dlp_errorlist[];
  133. extern char * dlp_strerror(int error);
  134.  
  135. extern int dlp_GetSysDateTime PI_ARGS((int sd, time_t * t));
  136.  
  137.   /* Get the time on the Pilot and return it as a local time_t value. */
  138.   
  139. extern int dlp_SetSysDateTime PI_ARGS((int sd, time_t time));
  140.  
  141.   /* Set the time on the Pilot using a local time_t value. */
  142.   
  143. extern int dlp_ReadStorageInfo PI_ARGS((int sd, int cardno, struct CardInfo * c));
  144.  
  145.  
  146. extern int dlp_ReadSysInfo PI_ARGS((int sd, struct SysInfo * s));
  147.  
  148.   /* Read the system information block. */
  149.  
  150. extern int dlp_ReadDBList PI_ARGS((int sd, int cardno, int flags, int start, struct DBInfo * info));
  151.  
  152.   /* flags must contain dlpDBListRAM and/or dlpDBListROM */
  153.  
  154. extern int dlp_FindDBInfo PI_ARGS((int sd, int cardno, int start, char * dbname, unsigned long type,
  155.                                unsigned long creator, struct DBInfo * info));
  156.   
  157. extern int dlp_OpenDB PI_ARGS((int sd, int cardno, int mode, char * name, int * dbhandle));
  158.  
  159.   /* Open a database on the Pilot. cardno is the target memory card (always
  160.      use zero for now), mode is the access mode, and name is the ASCII name
  161.      of the database.
  162.      
  163.      Mode can contain any and all of these values:  Read = 0x80
  164.                                                     Write = 0x40
  165.                                                     Exclusive = 0x20
  166.                                                     ShowSecret = 0x10
  167.   */
  168.   
  169. extern int dlp_CloseDB PI_ARGS((int sd, int dbhandle));
  170.  
  171.   /* Close an opened database using the handle returned by OpenDB. */
  172.  
  173. extern int dlp_CloseDB_All PI_ARGS((int sd));
  174.  
  175.   /* Variant of CloseDB that closes all opened databases. */
  176.  
  177. extern int dlp_DeleteDB PI_ARGS((int sd, int cardno, PI_CONST char * name));
  178.  
  179.   /* Delete a database.
  180.        cardno: zero for now
  181.        name: ascii name of DB. */
  182.   
  183. extern int dlp_CreateDB PI_ARGS((int sd, long creator, long type, int cardno,
  184.                  int flags, int version, PI_CONST char * name, int * dbhandle));
  185.  
  186.  /* Create database */                 
  187.                     
  188. extern int dlp_ResetSystem PI_ARGS((int sd));
  189.  
  190.  /* Require reboot of Pilot after HotSync terminates. */
  191.  
  192. extern int dlp_AddSyncLogEntry PI_ARGS((int sd, char * entry));
  193.  
  194.  /* Add an entry into the HotSync log on the Pilot.  Move to the next line
  195.     with \n, as usual. You may invoke this command once or more before
  196.     calling EndOfSync, but it is not required. */
  197.  
  198. extern int dlp_OpenConduit PI_ARGS((int sd));
  199.  
  200.  /* State that the conduit has been succesfully opened -- puts up a status
  201.      message on the Pilot, no other effect as far as I know. Not required.
  202.      */
  203.      
  204. extern int dlp_EndOfSync PI_ARGS((int sd, int status));
  205.  
  206.  /* Terminate HotSync. Required at the end of a session. The pi_socket layer
  207.     will call this for you if you don't.
  208.     
  209.     Status: dlpEndCodeNormal, dlpEndCodeOutOfMemory, dlpEndCodeUserCan, or
  210.             dlpEndCodeOther
  211.   */            
  212.  
  213. extern int dlp_AbortSync PI_ARGS((int sd));
  214.  
  215.  /* Terminate HotSync _without_ notifying Pilot. This will cause the Pilot
  216.     to time out, and should (if I remember right) lose any changes to
  217.     unclosed databases. _Never_ use under ordinary circumstances. If the
  218.     sync needs to be aborted in a reasonable manner, use EndOfSync with a
  219.     non-zero status. */
  220.    
  221. extern int dlp_ReadOpenDBInfo PI_ARGS((int sd, int dbhandle, int * records));
  222.  
  223.  /* Return info about an opened database. Currently the only information
  224.     returned is the number of records in the database. */
  225.  
  226.  
  227. extern int dlp_MoveCategory PI_ARGS((int sd, int handle, int fromcat, int tocat));
  228.  
  229. extern int dlp_WriteUserInfo PI_ARGS((int sd, struct PilotUser *User));
  230.  
  231.  /* Tell the pilot who it is. */
  232.  
  233. extern int dlp_ReadUserInfo PI_ARGS((int sd, struct PilotUser *User));
  234.  
  235.  /* Ask the pilot who it is. */
  236.  
  237. extern int dlp_ResetLastSyncPC PI_ARGS((int sd));
  238.  
  239.  /* Convenience function to reset lastSyncPC in the UserInfo to 0 */
  240.  
  241. extern int dlp_ReadAppBlock PI_ARGS((int sd, int fHandle, int offset,
  242.                            void *dbuf, int dlen));
  243.  
  244. extern int dlp_WriteAppBlock PI_ARGS((int sd, int fHandle, PI_CONST void *dbuf, int dlen));
  245.  
  246. extern int dlp_ReadSortBlock PI_ARGS((int sd, int fHandle, int offset, void *dbuf, int dlen));
  247.  
  248. extern int dlp_WriteSortBlock PI_ARGS((int sd, int fHandle, PI_CONST void *dbuf, int dlen));
  249.  
  250. extern int dlp_ResetDBIndex PI_ARGS((int sd, int dbhandle));
  251.  
  252.  /* Reset NextModified position to beginning */
  253.  
  254. extern int dlp_ReadRecordIDList PI_ARGS((int sd, int dbhandle, int sort,
  255.                          int start, int max, recordid_t * IDs, int *count));
  256.                          
  257. extern int dlp_WriteRecord PI_ARGS((int sd, int dbhandle, int flags,
  258.                  recordid_t recID, int catID, void *data, int length, recordid_t * NewID));
  259.  
  260.  /* Write a new record to an open database. 
  261.       Flags: 0 or dlpRecAttrSecret
  262.       RecID: a UniqueID to use for the new record, or 0 to have the
  263.              Pilot create an ID for you.
  264.       CatID: the category of the record
  265.       data:  the record contents
  266.       length: length of record. If -1, then strlen will be used on data
  267.       
  268.       NewID: storage for returned ID, or null. */
  269.  
  270. extern int dlp_DeleteRecord PI_ARGS((int sd, int dbhandle, int all, recordid_t recID));
  271.  
  272. extern int dlp_DeleteCategory PI_ARGS((int sd, int dbhandle, int category));
  273.  
  274. extern int dlp_ReadResourceByType PI_ARGS((int sd, int fHandle, unsigned long type, int id, void * buffer, 
  275.                           int* index, int* size));
  276.  
  277. extern int dlp_ReadResourceByIndex PI_ARGS((int sd, int fHandle, int index, void* buffer,
  278.                           unsigned long* type, int * id, int* size));
  279.  
  280. extern int dlp_WriteResource PI_ARGS((int sd, int dbhandle, unsigned long type, int id,
  281.                  PI_CONST void *data, int length));
  282.  
  283. extern int dlp_DeleteResource PI_ARGS((int sd, int dbhandle, int all, unsigned long restype, int resID));
  284.  
  285. extern int dlp_ReadNextModifiedRec PI_ARGS((int sd, int fHandle, void *buffer,
  286.                           recordid_t * id, int * index, int * size, int * attr, int * category));
  287.  
  288. extern int dlp_ReadNextModifiedRecInCategory PI_ARGS((int sd, int fHandle, int incategory, void* buffer,
  289.                           recordid_t* id, int* index, int* size, int* attr));
  290.  
  291. extern int dlp_ReadNextRecInCategory PI_ARGS((int sd, int fHandle, int incategory, void* buffer,
  292.                           recordid_t* id, int* index, int* size, int* attr));
  293.                           
  294. extern int dlp_ReadRecordById PI_ARGS((int sd, int fHandle, recordid_t id, void * buffer, 
  295.                           int * index, int * size, int * attr, int * category));
  296.  
  297. extern int dlp_ReadRecordByIndex PI_ARGS((int sd, int fHandle, int index, void * buffer, 
  298.                           recordid_t * id, int * size, int * attr, int * category));
  299.  
  300. extern int dlp_CleanUpDatabase PI_ARGS((int sd, int fHandle));
  301.  
  302.   /* Deletes all records in the opened database which are marked as archived
  303.      or deleted. */
  304.  
  305. extern int dlp_ResetSyncFlags PI_ARGS((int sd, int fHandle));
  306.  
  307.   /* For record databases, reset all dirty flags. For both record and
  308.      resource databases, set the last sync time to now. */
  309.  
  310. extern int dlp_CallApplication PI_ARGS((int sd, unsigned long creator, unsigned long type, int action,
  311.                         int length, void * data,
  312.                         unsigned long * retcode, int maxretlen, int * retlen, void * retdata));
  313.   /* 32-bit retcode and data over 64K only supported on v2.0 Pilots */
  314.                                                 
  315. extern int dlp_ReadFeature PI_ARGS((int sd, unsigned long creator, unsigned int num, 
  316.                            unsigned long * feature));
  317.  
  318. extern int dlp_ReadNetSyncInfo PI_ARGS((int sd, struct NetSyncInfo * i));
  319.  
  320.   /* PalmOS 2.0 only */
  321.  
  322. extern int dlp_WriteNetSyncInfo PI_ARGS((int sd, struct NetSyncInfo * i));
  323.                         
  324.   /* PalmOS 2.0 only */
  325.  
  326. extern int dlp_ReadAppPreference PI_ARGS((int sd, unsigned long creator, int id, int backup,
  327.                           int maxsize, void* buffer, int * size, int * version));
  328.  
  329. extern int dlp_WriteAppPreference PI_ARGS((int sd, unsigned long creator, int id, int backup,
  330.                           int version, void * buffer, int size));
  331.  
  332. struct RPC_params;
  333.  
  334. extern int dlp_RPC PI_ARGS((int sd, struct RPC_params * p, unsigned long * result));
  335.  
  336. #ifdef __cplusplus
  337. }
  338. #endif
  339.  
  340. #endif /*_PILOT_DLP_H_*/
  341.